package com.ss.android.newmedia.activity.browser;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.MenuItem;
import android.webkit.WebView;
import android.widget.PopupMenu;
import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.browser.R;

final class b implements PopupMenu.OnMenuItemClickListener {
    private final BrowserActivity a;

    b(BrowserActivity arg1) {
        this.a = arg1;
    }

    public final boolean onMenuItemClick(MenuItem arg6) {
        BrowserActivity v1_2;
        Object v0 = null;
        WebView v1 = this.a.d();
        if(v1 != null) {
            int v2 = arg6.getItemId();
            String v1_1 = v1.getUrl();
            if(v2 == R.id.af6) {
                BrowserActivity v2_1 = this.a;
                if(android.support.design.a.isTextEmpty(v1_1)) {
                    return true;
                }

                if(v2_1.c != null) {
                    v0 = v2_1.c.get();
                }

                if((v0 instanceof com.ss.android.newmedia.activity.browser.BrowserActivity.a)) {
                    ((com.ss.android.newmedia.activity.browser.BrowserActivity.a)v0).a(v1_1);
                    return true;
                }

                try {
                    Intent v0_2 = new Intent();
                    v0_2.setData(Uri.parse(v1_1));
                    v0_2.setAction("android.intent.action.VIEW");
                    v2_1.startActivity(v0_2);
                }
                catch(Exception v0_1) {
                    v0_1.printStackTrace();
                }

                return true;
            }

            if(v2 == R.id.af5) {
                BrowserActivity v0_3 = this.a;
                if(android.support.design.a.isTextEmpty(v1_1)) {
                    return true;
                }

                com.bytedance.common.utility.a.a.a(((Context)v0_3), "", ((CharSequence)v1_1));
                UIUtils.showImageToast(((Context)v0_3), R.drawable.doneicon_popup_textpage, R.string.a0s);
                return true;
            }

            if(v2 == R.id.refresh) {
                v1_2 = this.a;
                if(v1_2.c != null) {
                    v0 = v1_2.c.get();
                }

                if(v0 == null) {
                    return true;
                }

                if(!((e)v0).isActive()) {
                    return true;
                }

                ((e)v0).m();
                return true;
            }

            if(v2 == R.id.af7) {
                v1_2 = this.a;
                if(v1_2.c != null) {
                    v0 = v1_2.c.get();
                }

                if(!(v0 instanceof com.ss.android.newmedia.activity.browser.BrowserActivity.a)) {
                    return true;
                }

                ((com.ss.android.newmedia.activity.browser.BrowserActivity.a)v0).c();
            }
        }

        return true;
    }
}

